package Config;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;

import javax.servlet.Filter;

public class Nginx extends AbstractDispatcherServletInitializer {

    @Override
    protected WebApplicationContext createServletApplicationContext(){
        AnnotationConfigWebApplicationContext actwx=new AnnotationConfigWebApplicationContext();
        actwx.register(MvcScan.class);
        return actwx;
    }

    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    @Override
    protected WebApplicationContext createRootApplicationContext() {
        return null;
    }

    @Override
    protected Filter[] getServletFilters() {
        CharacterEncodingFilter cef=new CharacterEncodingFilter();
        cef.setEncoding("utf-8");
        return new Filter[]{cef};
    }
}
